package com.example.replacebooks.service;

import cn.hutool.core.date.DateUtil;
import com.example.replacebooks.entity.Bookorder;
import com.example.replacebooks.entity.Orders_Bookorder;
import com.example.replacebooks.entity.Params;
import com.example.replacebooks.mapper.BookinfoMapper;
import com.example.replacebooks.mapper.BookorderMapper;
import com.example.replacebooks.mapper.Orders_BookorderMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class Orders_BookorderService {
    @Resource
    private Orders_BookorderMapper orders_bookorderMapper;


    public List<Orders_Bookorder> findAll(){
        return orders_bookorderMapper.selectAll();
    }

    public PageInfo<Orders_Bookorder> findBySearch(Params params){
        // 开启分页查询
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        // 接下来的查询会自动按照当前开启的分页查询
        List<Orders_Bookorder> list = orders_bookorderMapper.findBySearch(params);
        return PageInfo.of(list);
    }

    public void add(Orders_Bookorder orders_bookorder) {
        // 新增就好，没有更新
        orders_bookorderMapper.insertSelective(orders_bookorder);
    }

    public void delete(Integer id) {
        orders_bookorderMapper.deleteByPrimaryKey(id);
    }

    public List<Orders_Bookorder> findByBookorderid(Integer bookorderid) {
        List<Orders_Bookorder> orders_bookorder = orders_bookorderMapper.findByBookOrderid(bookorderid);
        return orders_bookorder;
    }
}
